import React from 'react';
import { motion } from 'framer-motion';

interface SpinAnimationProps {
  children: React.ReactNode;
  className?: string;
  speed?: number;
  direction?: 'clockwise' | 'counterclockwise';
}

const SpinAnimation: React.FC<SpinAnimationProps> = ({ 
  children, 
  className = '',
  speed = 20,
  direction = 'clockwise'
}) => {
  const rotateDirection = direction === 'clockwise' ? 360 : -360;

  return (
    <motion.div
      className={className}
      animate={{ 
        rotate: [0, rotateDirection]
      }}
      transition={{ 
        duration: speed,
        repeat: Infinity,
        ease: "linear"
      }}
    >
      {children}
    </motion.div>
  );
};

export default SpinAnimation;